#ifndef SPI_SW_HALL_H
#define SPI_SW_HALL_H

#include "mytype.h"

#ifdef __cplusplus
extern "C"
{
#endif

	typedef const struct
	{
		void (*cs_out_high)(void);
		void (*cs_out_low)(void);

		void (*sck_out_high)(void);
		void (*sck_out_low)(void);

		void (*mosi_out_high)(void);
		void (*mosi_out_low)(void);

		uu8 (*miso_st_get)(void); 
        
		uu8 miso_mode;			
        uu8 sck_mode;           
	} spi_cfg_type;

	void sw_spi_init(spi_cfg_type *spi);
	void sw_spi_cs(spi_cfg_type *spi, uu8 cs);

	uu8 sw_spi8_rw(spi_cfg_type *spi, uu8 wreg);
	void sw_spi8_write(spi_cfg_type *qpi, uu8 *wdata, uint16_t len);
	void sw_spi8_read(spi_cfg_type *spi, uu8 *rdata, uint16_t len);

	uu8 sw_spi8_rw_lsb(spi_cfg_type *spi, uu8 wreg);
	void sw_spi8_write_lsb(spi_cfg_type *qpi, uu8 *wdata, uint16_t len);
	void sw_spi8_read_lsb(spi_cfg_type *spi, uu8 *rdata, uint16_t len);

	uu32 sw_spi_clks_rw(spi_cfg_type *spi, uu32 wreg, uu8 sclks);
	void sw_spi_clks_write(spi_cfg_type *spi, uu32 wreg, uu8 sclks);
	uu32 sw_spi_clks_read(spi_cfg_type *spi, uu8 sclks);

	uu32 sw_spi_clks_rw_lsb(spi_cfg_type *spi, uu32 wreg, uu8 sclks);
	void sw_spi_clks_write_lsb(spi_cfg_type *spi, uu32 wreg, uu8 sclks);
	uu32 sw_spi_clks_read_lsb(spi_cfg_type *spi, uu8 sclks);

	typedef const struct
	{
		void (*cs_out)(char cs);

		void (*sck_out_high)(void); 
		void (*sck_out_low)(void);

		void (*io_out)(uu32 qio); 
		uu32 (*io_in)(void);	  

	} qpi_cfg_type;

	void sw_qpi8_write(qpi_cfg_type *qpi, uu8 *wdata, uint16_t len);
	void sw_qpi32_write(qpi_cfg_type *qpi, uu32 *wdata, uint16_t len);
	void sw_qpi8_read(qpi_cfg_type *qpi, uu8 *rdata, uint16_t len);
	void sw_qpi32_read(qpi_cfg_type *qpi, uu32 *rdata, uint16_t len);

	void sw_qpi8_write_lsb(qpi_cfg_type *qpi, uu8 *wdata, uint16_t len);
	void sw_qpi32_write_lsb(qpi_cfg_type *qpi, uu32 *wdata, uint16_t len);
	void sw_qpi8_read_lsb(qpi_cfg_type *qpi, uu8 *rdata, uint16_t len);
	void sw_qpi32_read_lsb(qpi_cfg_type *qpi, uu32 *rdata, uint16_t len);

#ifdef __cplusplus
}
#endif

#endif 
